<template>
	<view class="body">
		<view class="header">
			<infomationVue :query="query"></infomationVue>
		</view>
		<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="scrolltolower">
			<view class="comlum_Y" v-if="list.length">
				<view v-for="(item,index) in list" :key="index" class="Item">
					<view class="headers">
						上课时间：{{item.class_time}}
					</view>
					<view class="center">
						<image :src="item.image" mode="aspectFill" class="img"></image>
						<view class="right">
							<view class="title">
								{{item.title}}
							</view>
							<view class="sound">
								<view class="sound_left">
									<text class="size1">第</text>
									<text class="size2">{{item.that}}</text>
									<text class="size1">节丨共{{item.classes}}节</text>
								</view>
								<view class="size1">
									单价￥{{item.cost}}
								</view>
							</view>
						</view>
					</view>
					<view class="bottom">
						<view class="shop_box">
							<image :src="item.shop_category_image" mode="aspectFill" class="logos"></image>
							<view class="shop_size">
								{{item.shop_name}}
							</view>
						</view>
						<view class="coach_box">
							<view class="img_box">
								<image :src="item.coach_avatar" mode="aspectFill" class="imgs"></image>
								<view class="tag">
									主教
								</view>
							</view>
							<view class="coach_right">
								<view class="name">
									{{item.coach_username}}
								</view>
								<view class="phone_box">
									<image :src="$IMG_URL('/static/test/phone.png')" mode="aspectFill" class="phone_logo"></image>
									<view class="phone_numnber">
										{{item.coach_mobile}}
									</view>
								</view>
							</view>
							<view class="btn" @click="opentelephoneShow(item.coach_mobile)">
								拨打
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" />
			</view>
			<empty v-else :content="'上课记录'"></empty>
		</scroll-view>
		<telephone :telephoneShow="telephoneShow" :telephone="mobileNumber" @cancel="callCancel" @sure="callSure">
		</telephone>
	</view>
</template>

<script>
	import infomationVue from '../../coach/components/infomation.vue'
	import empty from '@/components/empty.vue'
	import telephone from '@/components/telephone.vue'
	import{
		classList
	} from '@/api/manager.js'
	export default{
		components:{
			infomationVue,
			empty,
			telephone
		},
		data(){
			return{
				status: 'loadmore',
				mobileNumber:'',
				telephoneShow: false,
				infomation:{
					user_id:'',
					page:1
				},
				query:{},
				list:[]
			}
		},
		onLoad(e) {
			this.infomation.user_id = e.user_id
			this.getclassList()
		},
		methods:{
			scrolltolower(){
				this.infomation.page++
				this.getclassList()
			},
			opentelephoneShow(mobile){
				this.telephoneShow = true
				this.mobileNumber = mobile
			},
			callSure() {
				let that = this
				uni.makePhoneCall({
					phoneNumber: that.mobileNumber, // 必填，需要拨打的电话号码
					success: function() {
						console.log('拨打电话成功！');
						// 这里可以添加拨打成功后的逻辑，比如提示用户
					},
					fail: function(err) {
						console.log('拨打电话失败：', err);
						// 这里可以添加拨打失败后的逻辑，比如提示用户错误原因
					}
				});
				this.telephoneShow = false
			},
			callCancel() {
				this.telephoneShow = false
			},
			getclassList(){
				classList(this.infomation).then(({data:res})=>{
					console.log('res', res);
					if(res.code == 1){
						this.query = res.data.user_info
						const list = []
						this.status = 'loading'
						if (this.query.page > res.data.all_page) {
							console.log('nomore');
							this.status = 'nomore'
							return false
						} else {
							console.log('more');
							this.status = 'more'
							this.list = this.list.concat(res.data.list)
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #e9e9e9;
	}
	.body{
		display: flex;
		flex-direction: column;
		align-items: center;
		.header{
			
		}
		.scroll-view{
			height: 88vh;
			.comlum_Y{
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-top: 24rpx;
				.Item{
					width: 702rpx;
					background: #ffffff;
					border-radius: 16rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-bottom: 20rpx;
					padding: 24rpx;
					.headers{
						width: 100%;
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC-Bold;
						font-weight: 700;
						text-align: left;
						color: #333333;
						padding-bottom: 22rpx;
						border-bottom: 1rpx solid #e9e9e9;
					}
					.center{
						padding: 26rpx 0 22rpx;
						width: 100%;
						display: flex;
						flex-direction: row;
						border-bottom: 1rpx solid #e9e9e9;
						.img{
							width: 160rpx;
							height: 120rpx;
							background: rgba(0,0,0,0.00);
							border-radius: 16rpx;
							margin-right: 20rpx;
						}
						.right{
							display: flex;
							flex-direction: column;
							flex: 1;
							.title{
								font-size: 32rpx;
								font-family: PingFang SC, PingFang SC-Bold;
								font-weight: 700;
								text-align: left;
								color: #333333;
								margin-bottom: 8rpx;
							}
							.sound{
								display: flex;
								flex-direction: row;
								align-items: center;
								width: 100%;
								.size1{
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Medium;
									font-weight: 500;
									text-align: left;
									color: #999999;
								}
								.size2{
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Medium;
									font-weight: 500;
									text-align: left;
									color: #73F0EA;
								}
								.sound_left{
									flex: 1;
								}
							}
						}
					}
					.bottom{
						padding-top: 28rpx;
						width: 100%;
						display: flex;
						flex-direction: column;
						.shop_box{
							display: flex;
							flex-direction: row;
							align-items: center;
							margin-bottom: 22rpx;
							.logos{
								width: 114rpx;
								height: 36rpx;
								margin-right: 12rpx;
							}
							.shop_size{
								font-size: 28rpx;
								font-family: PingFang SC, PingFang SC-Bold;
								font-weight: 700;
								text-align: right;
								color: #333333;
							}
						}
						.coach_box{
							display: flex;
							flex-direction: row;
							align-items: center;
							.img_box{
								width: 92rpx;
								height: 92rpx;
								position: relative;
								margin-right: 20rpx;
								.imgs{
									width: 92rpx;
									height: 92rpx;
									background: rgba(0,0,0,0.00);
									border-radius: 50%;
								}
								.tag{
									position: absolute;
									left: 50%;
									bottom: -10%;
									transform: translate(-50%, 0);
									width: 60rpx;
									height: 36rpx;
									background: #73F0EA;
									border-radius: 8rpx;
									font-size: 22rpx;
									font-family: PingFang SC, PingFang SC-Medium;
									font-weight: 500;
									text-align: left;
									color: #ffffff;
									display: flex;
									align-items: center;
									justify-content: center;
								}
							}
							.coach_right{
								display: flex;
								flex-direction: column;
								flex: 1;
								.name{
									font-size: 28rpx;
									font-family: PingFang SC, PingFang SC-Bold;
									font-weight: 700;
									text-align: left;
									color: #333333;
									margin-bottom: 12rpx;
								}
								.phone_box{
									display: flex;
									flex-direction: row;
									align-items: center;
									flex: 1;
									.phone_logo{
										width: 20rpx;
										height: 30rpx;
										margin-right: 7rpx;
									}
									.phone_numnber{
										font-size: 28rpx;
										font-family: PingFang SC, PingFang SC-Medium;
										font-weight: 500;
										text-align: left;
										color: #666666;
									}
								}
								
							}
							.btn{
								transform: rotateZ(360deg);
								width: 112rpx;
								height: 64rpx;
								border: 1rpx solid #73F0EA;
								border-radius: 16rpx;
								font-size: 28rpx;
								font-family: PingFang SC, PingFang SC-Bold;
								font-weight: 700;
								text-align: center;
								color: #73F0EA;
								display: flex;
								align-items: center;
								justify-content: center;
							}
						}
					}
				}
			}
		}
	}
</style>